export function list2Tree(list, pid) {
  const result = []
  list.forEach((item) => {
    if (item.pid === pid) {
      // 自己调用自己
      const children = list2Tree(list, item.id)
      // 判断下一层有没有
      if (children.length > 0) {
        item.children = children
      }
      result.push(item)
    }
  })
  return result
}
